function V = SIGEv(ma_m,ma_a,ma_g,ma_nu,ma_gam,Sigma);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%This is part of the set of files that accompany the article:       %
%Mankiw, N. Gregory and Ricardo Reis (2007) "Sticky Information in  %
%General Equilibrium," Journal of the European Economic Association,%
%forthcoming. See the appendix of the NBER or CEPR working paper    %
%versions for a detailed explanation of the algorithms.             %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Please cite if you use the programs. I do not provide tech support.%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Last revised: August 30, 2006                                      %
%Written by: Ricardo Reis                                           %
%Input: ma solutions and SIgma matrix                               %
%Output: V matrix                                                   %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

global T N K;

%%%%STEP 1: Build Omega matrix in Proposition 2 %%%%%
PHI = [];
PHIreverse =[] ;
for i=1:T
    temp = [ma_m(i,:)' ma_a(i,:)' ma_g(i,:)' ma_nu(i,:)' ma_gam(i,:)'];
    PHI = [PHI; temp];
    PHIreverse = [temp ; PHIreverse];
end
Omega=PHI;
for i=1:N-1
    temp=[PHIreverse(K*(T-1-i)+1:K*(T-1),1:K); PHI(1:K*(T-i),1:K)];
    Omega = [Omega  temp];
end

%%%%STEP 2: V matrix in Proposition 2 %%%%%
V = Omega * kron(eye(N),Sigma) * Omega';